<?php

namespace IDock\Insurance\HBIC\Request;

use IDock\Http\RequestFormat;
use IDock\Http\RequestMethod;
use IDock\Insurance\HBIC\Response\DownloadInsuranceResponse;
use IDock\Visitor\EPolicyDownloadVisitor;

class DownloadInsuranceRequest extends AllHBICRequest
{
    public $requestType = 'A20';

    protected $response = DownloadInsuranceResponse::class;

    protected $urlTip = '下载电子保单接口';
    public $ciRequestUel = 'interflow/api/sftp/v3/download/policy/jqx/';

    public $biRequestUel = 'interflow/api/sftp/v3/download/policy/syx/';

    public $method = RequestMethod::GET;

    public $token = '';

    public $format = RequestFormat::JSON;

    /*** @var EPolicyDownloadVisitor $visitor */
    protected $visitor;

    public function generate(): array
    {
        $type = $this->visitor->argc['type'] ?? '';
        $url = $sign = '';
        if ($type == 'ci') {
            $sign = md5(date('Ymd') . 'policyjqx' . $this->visitor->policyNo);
            $url = $this->ciRequestUel . $this->visitor->policyNo;

        }
        if ($type == 'bi') {
            $sign = md5(date('Ymd') . 'policysyx' . $this->visitor->policyNo);
            $url = $this->biRequestUel . $this->visitor->policyNo;

        }
        return [
            'url' => $url,
            'sign' => $sign
        ];
    }

    public function getStaffValue(&$comCode)
    {
        $comCode = $this->visitor->argc['comCode'] ?? '';
    }

    public function responseLogs($uuid, $data)
    {

    }
}
